package cn.ulc.socket.admin.controller;

import cn.ulc.common.model.param.PaginationParam;
import cn.ulc.common.util.Result;
import cn.ulc.socket.admin.model.dto.order.OrderListDTO;
import cn.ulc.socket.admin.service.order.OrderServ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Min;

@Validated
@RestController
@RequestMapping(value = "/orders")
public class OrderCtrl {
    @Autowired
    OrderServ orderServ;

    @GetMapping
    public Result findListPage(String orderNo, String status, String begin, String end , PaginationParam pager) {
        OrderListDTO dto = orderServ.findListPage(orderNo,status,begin , end ,pager);
        return Result.success(dto);
    }
    @GetMapping("/rider/list")
    public Result findRiderListPage(Long riderId,String orderNo, String begin, String end , PaginationParam pager) {
        OrderListDTO dto = orderServ.findRiderListPage(riderId,orderNo,begin , end ,pager);
        return Result.success(dto);
    }
    @PostMapping("/dispatch")
    public Result dispatchOrder(String orderNo, Long riderId) {
        Boolean result = orderServ.dispatchOrder(orderNo,riderId);
        return Result.success(result,true);
    }
    @PutMapping("/refund/{orderNo}")
    public Result refund(@PathVariable String orderNo) {
        Boolean result = orderServ.refund(orderNo);
        return Result.success(result,true);
    }

}
